package com.day2sockettest;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class TestInetAddr {
    public static void main(String[] args){
        try {
            InetAddress inet=InetAddress.getByName("www.baidu.com");
            System.out.println(inet);
            System.out.println(inet.getHostName());
            System.out.println(inet.getHostAddress());

            InetAddress inet1=InetAddress.getLocalHost();
            System.out.println(inet1);  //域名
            System.out.println(inet1);  //ip
        }catch (UnknownHostException e){
            e.printStackTrace();
        }
    }

}
